package com.shixu.framework.plugins.weixin.bean;

import java.util.Date;

public class AccessToken {
	 // 获取到的凭证  
    private String token;  
    // 刷新用token
    private String refreshToken;
    
    public String getRefreshToken() {
		return refreshToken;
	}

	public void setRefreshToken(String refreshToken) {
		this.refreshToken = refreshToken;
	}

	// 凭证有效时间，单位：秒  
    private int expiresIn;
    
    private long updateTime;
    

	public long getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(long updateTime) {
		this.updateTime = updateTime;
	}

	public String getToken() {  
        return token;  
    }  
  
    public void setToken(String token) {  
        this.token = token;  
    }  
  
    public int getExpiresIn() {  
        return expiresIn;  
    }  
  
    public void setExpiresIn(int expiresIn) {  
        this.expiresIn = expiresIn;  
    }  
    
    /**
     * 是否过期 
     * default: true
     * @return true|false
     */
    public boolean isExpired(){
    	long currentTime = new Date().getTime();
    	long elapsedTime = (currentTime - this.updateTime)/1000 + 200;
    	
    	System.out.println("elapsedTime"+elapsedTime);
    	
    	return (this.expiresIn <= elapsedTime);
    }
    

}
